<h2><?php __('Files Archive') ?></h2>
<?php echo $form->create('Committee',array('url'=>array('controller'=>'attachments','action'=>'index','committee'=>$dcommittee['Committee']['short_name']))); ?>
<fieldset>
    <legend>
		<?php __('Please select your criteria below:');?>  
    </legend>
 
    <div class="fieldset-inside">
    <?php
        echo $html->div('input',$form->label(__('File Name',true)).'&nbsp;'.$form->text('Search.name'));
        
        echo $html->div('',$form->label('Search.type', __('Type',true)).'&nbsp;'.
            $form->select('Search.type',
                $options = array(
                    'Meeting'=>__('Meeting file',true),
                    'Decision'=>__('Decision file',true),
                    'Userstatus'=>__('Userstatus file',true),
                    'Groupstatus'=>__('Groupstatus',true)
                ),
                isset($curtype)?$curtype:null,
                '',
                __(' ---please select--- ',true)     
            )
        );
        echo $html->div('',$form->label('Search.meeting', __('Meeting',true)).'&nbsp;'.
            $form->select(
                'Search.meeting',
                $options = $meetings,
                (isset($cursearch_meeting) && $cursearch_meeting!='')?$cursearch_meeting:null,
                '',
                __(' ---please select--- ',true)
            )
        );
        $item_name = strlen($dcommittee['Committee']['item_name'])>2 ? $dcommittee['Committee']['item_name'] : 'Project';
        echo $html->div('',$form->label('Search.item', ucwords($item_name)).'&nbsp;'.        
            $form->select(
                'Search.item',
                $options = $projects,
                (isset($cursearch_project) && $cursearch_project!='')?$cursearch_project:null,
                '',
                __(' ---please select--- ',true)
            )
        );
        echo $html->div('input',$form->label(__('Upload Date',true).' ('.__('Year',true).')').'&nbsp;'.$form->select(
            'Search.year',
            array($years),
            (isset($cursearch_year) && $cursearch_year!='')?$cursearch_year:null,
            '',
            __(' ---please select--- ',true)
        ));
        echo '&nbsp;';
        echo $form->button(__('Search!', true), array('type'=>'submit'));
        ?>
        &nbsp;
    </div>
</fieldset>
<?php echo $form->end();?>
&nbsp;
<?php if(isset($meetingfiles) && !empty($meetingfiles)):?>
    <h4><?php __('Meeting Files');?></h4>
    <table cellpadding='0' cellspacing='0'>
        <tr><th width='2%'>Bil.</th><th width='37%'><?php __('Meeting');?></th><th width='13%'><?php __('Meeting Num');?></th><th width='8%'><?php __('Meeting Date');?></th><th><?php __('File');?></th><th width='8%'><?php __('Updated');?></th></tr>
        <?php
        if (!count($meetingfiles)) {
            echo "<tr><td colspan='5'>".__('No record found',true)."</td></tr>";
        }
        $i=1;
        foreach($meetingfiles as $meetingfile){
        ?>
            <tr>
                <td><?php echo $i++.'. ';?></td>
                <td><?php echo $html->link($meetingfile['Meeting']['meeting_title'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'view','id'=>$meetingfile['Meeting']['id']));?></td>
                <td><?php echo $html->link($meetingfile['Meeting']['meeting_num'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'view','id'=>$meetingfile['Meeting']['id']));?></td>
                <td><?php echo date(Configure::read('date_format'),strtotime($meetingfile['Meeting']['meeting_date']));?></td>
                <td>
                    <?php 
                    if($meetingfile['Attachment']['viewpermission']){
                        echo $html->link($meetingfile['Attachment']['filename'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'attachment','id'=>$meetingfile['Attachment']['id']));
                    }else{
                        echo $meetingfile['Attachment']['filename'];
                    }
                    ?>
                </td>
                <td><?php echo date(Configure::read('date_format'),strtotime($meetingfile['Attachment']['modified']));?></td>
            </tr>
        <?php } ?>
    </table>
<?php endif; ?>

<?php if(isset($decisionfiles) && !empty($decisionfiles)):?>
    <h4><?php __('Decision Files');?></h4>
    <table cellpadding='0' cellspacing='0'>
        <tr><th width='2%'>Bil.</th><th width='50%'><?php __('Decision');?></th><th width='8%'><?php __('Decision Date');?></th><th><?php __('File');?></th><th width='8%'><?php __('Updated');?></th><th width='8%'><?php __('Private');?></th></tr>
        <?php
        $i=1;
        foreach($decisionfiles as $decisionfile){
        ?>
            <tr>
                <td><?php echo $i++.'. ';?></td>
                <td><?php echo $html->link($text->truncate(strip_tags($decisionfile['Decision']['description']),100),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'view','id'=>$decisionfile['Decision']['id']),null,null,false);?></td>
                <td><?php echo date(Configure::read('date_format'),strtotime($decisionfile['Decision']['updated']));?></td>
                <td>
                    <?php 
                    if ($decisionfile['Attachment']['viewpermission']){
                        echo $html->link($decisionfile['Attachment']['filename'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'attachment','id'=>$decisionfile['Attachment']['id']));
                    }else{
                        echo $decisionfile['Attachment']['filename'];
                    }
                    ?>
                </td>
                <td><?php echo date(Configure::read('date_format'),strtotime($decisionfile['Attachment']['modified']));?></td>
                <td>
                    <?php 
                    ($decisionfile['Attachment']['private'])?$a=$html->image('icons/lock.png',array('title'=>__('Private',true))):$a='-';
                    echo $a;
                    ?>
                </td>
            </tr>
        <?php } ?>
    </table>
<?php endif; ?>

<?php if(isset($userstatusfiles) && !empty($userstatusfiles)):?>
    <h4><?php __('User Status Files');?></h4>
    <table cellpadding='0' cellspacing='0'>
        <tr><th width='2%'>Bil.</th><th width='50%'><?php __('Status');?></th><th width='8%'><?php __('Status Date');?></th><th><?php __('File');?></th><th width='8%'><?php __('Updated');?></th><th width='8%'><?php __('Private');?></th></tr>
        <?php
        $i=1;
        foreach($userstatusfiles as $userstatusfile){
        ?>
            <tr>
                <td><?php echo $i++.'. ';?></td>
                <td><?php echo $html->link($text->truncate($userstatusfile['Userstatus']['description'],100),router::url('../../'.$dcommittee['Committee']['short_name'].'/decisions/view/'.$userstatusfile['Userstatus']['decision_id'].'#user'.$userstatusfile['Userstatus']['id']));?></td>
                <td><?php echo date(Configure::read('date_format'),strtotime($userstatusfile['Userstatus']['action_date']));?></td>
                <td>
                    <?php 
                    if ($userstatusfile['Attachment']['viewpermission']){
                        echo $html->link($userstatusfile['Attachment']['filename'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'userstatuses','action'=>'attachment','id'=>$userstatusfile['Attachment']['id']));
                    }else{
                        echo $userstatusfile['Attachment']['filename'];
                    }
                    ?>
                </td>
                <td><?php echo date(Configure::read('date_format'),strtotime($userstatusfile['Attachment']['modified']));?></td>
                <td>
                    <?php 
                    ($userstatusfile['Attachment']['private'])?$a=$html->image('icons/lock.png',array('title'=>__('Private',true))):$a='-';
                    echo $a;
                    ?>
                </td>
            </tr>
        <?php } ?>
    </table>
<?php endif; ?>

<?php if(isset($groupstatusfiles) && !empty($groupstatusfiles)):?>
    <h4><?php __('Group Status Files');?></h4>
    <table cellpadding='0' cellspacing='0'>
        <tr><th width='2%'>Bil.</th><th width='50%'><?php __('Status');?></th><th width='8%'><?php __('Status Date');?></th><th><?php __('File');?></th><th width='8%'><?php __('Updated');?></th><th width='8%'><?php __('Private');?></th></tr>
        <?php
        $i=1;
        foreach($groupstatusfiles as $groupstatusfile){
        ?>
            <tr>
                <td><?php echo $i++.'. ';?></td>
                <td><?php echo $html->link($text->truncate($groupstatusfile['Groupstatus']['description'],100),array('controller'=>'decisions','action'=>'view','committee'=>$dcommittee['Committee']['short_name'],$groupstatusfile['Groupstatus']['decision_id'].'#group'.$groupstatusfile['Groupstatus']['id']));?></td>
                <td><?php echo date(Configure::read('date_format'),strtotime($groupstatusfile['Groupstatus']['action_date']));?></td>
                <td>
                    <?php 
                    if($groupstatusfile['Attachment']['viewpermission']){
                        echo $html->link($groupstatusfile['Attachment']['filename'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'groupstatuses','action'=>'attachment','id'=>$groupstatusfile['Attachment']['id']));
                    }else{
                        echo $groupstatusfile['Attachment']['filename'];
                    }
                    ?>
                </td>
                <td><?php echo date(Configure::read('date_format'),strtotime($groupstatusfile['Attachment']['modified']));?></td>
                <td>
                    <?php 
                    ($groupstatusfile['Attachment']['private'])?$a=$html->image('icons/lock.png',array('title'=>__('Private',true))):$a='-';
                    echo $a;
                    ?>
                </td>
            </tr>
        <?php } ?>
    </table>
<?php endif; ?>
